<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>3D翻转卡</title>
		<style type="text/css">
			html,
body {
  height: 100%;
}
body {
  padding: 30px;
  background-color: #f9f9f9;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
}
.fx-wrap {
  display: inline-block;
  padding-top: 20px;
  padding-bottom: 20px;
  padding-left: 2px;
  padding-right: 2px;
  overflow: hidden;
}
.fx-wrap .card {
  perspective: 1000px;
  width: 324px;
  height: 204px;
  position: relative;
}
.fx-wrap .card>.front,
.fx-wrap .card>.back {
  transition: transform 3s, z-index 3s 0s, box-shadow 3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  will-change: transform;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  border-radius: 4px;
  background-color: #fff;
  backface-visibility: hidden;
}
.fx-wrap .card>.front:before,
.fx-wrap .card>.back:before {
  transition: all 1s;
  content: '';
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-image: linear-gradient(135deg, rgba(238,238,238,0) 0%, rgba(255,255,255,0) 36%, rgba(255,255,255,0.4) 36%, rgba(255,255,255,0.4) 68%, rgba(247,247,247,0) 69%, rgba(238,238,238,0) 70%);
  background-repeat: no-repeat;
  background-position: 324px 0;
  pointer-events: none;
  z-index: 20;
}
.fx-wrap .card>.front>*,
.fx-wrap .card>.back>* {
  height: 100%;
}
.fx-wrap .card>.front .image,
.fx-wrap .card>.back .image {
  float: left;
}
.fx-wrap .card>.front .text,
.fx-wrap .card>.back .text {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 216px;
  float: right;
}
.fx-wrap .card>.front .text button.flip,
.fx-wrap .card>.back .text button.flip {
  border-radius: 9999em;
  width: 30px;
  height: 30px;
  margin: 10px;
  border: 0;
  background-color: #ddd;
  color: #fff;
  font-size: 1.5em;
  float: right;
  flex: 1;
  outline: 0;
  transition: background-color 0.3s ease-in, transform 0.4s;
  transition-delay: 0.1s;
}
.fx-wrap .card>.front .text button.flip:hover,
.fx-wrap .card>.back .text button.flip:hover {
  background-color: #16a8cf;
}
.fx-wrap .card>.front .text button.flip:focus,
.fx-wrap .card>.back .text button.flip:focus {
  transform: rotate(-360deg);
}
.fx-wrap .card>.front .text p,
.fx-wrap .card>.back .text p {
  margin: 30px auto;
  width: 80%;
  flex: 2;
}
.fx-wrap .card>.front .text a,
.fx-wrap .card>.back .text a {
  text-transform: uppercase;
  margin: 10px auto;
  text-align: right;
  width: 80%;
  display: block;
  flex: 1;
}
.fx-wrap .card>.front .image,
.fx-wrap .card>.back .image {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  background-size: cover;
  width: 108px;
  background-color: #f5f5f5;
  position: relative;
}
.fx-wrap .card>.front .image .heading,
.fx-wrap .card>.back .image .heading {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 10px;
  font-size: 1.5em;
  text-align: right;
  color: #fff;
  text-transform: uppercase;
}
.fx-wrap .card>.front {
  z-index: 2;
  transform: rotateY(0deg);
}
.fx-wrap .card>.back {
  z-index: 1;
  transform: rotateY(180deg);
}
.fx-wrap .card>.back header,
.fx-wrap .card>.back .text {
  width: 100%;
}
.fx-wrap .card>.back header b,
.fx-wrap .card>.back .text b {
  color: #0098a6;
  width: 80%;
  margin: 0 auto;
}
.fx-wrap .card>.back header p,
.fx-wrap .card>.back .text p {
  margin: 20px auto;
}
.fx-wrap .card.flip-it>.front {
  transform: rotateY(-180deg);
  z-index: 1;
}
.fx-wrap .card.flip-it>.back {
  transform: rotateY(0deg);
  z-index: 2;
}
.fx-wrap .card.flip-it>.front:before,
.fx-wrap .card.flip-it>.back:before {
  background-position: -324px 0;
}

		</style>
	</head>
	<body>
		<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css">
<div class="fx-wrap">
  <div class="card" data-href="#">
    <div class="front">
      <div class="image">
        <p class="heading">aqua</p>
      </div>
      <div class="text">
        <header class="clearfix">
          <button class="flip"><span class="zmdi zmdi-replay"></span></button>
        </header>
        <p>Hello, Click the turn button to watch me shine!</p><a href="#">Action</a>
      </div>
    </div>
    <div class="back">
      <div class="text">
        <header class="clearfix">
          <button class="flip"><span class="zmdi zmdi-replay"></span></button>
        </header><b>"You can flip me all day."</b>
        <p>I have flexbox with fallbacks, I'm not browser prefixed (so watch out, this is a prototype) but my animations are pure css if your into that sort of thing.</p>
      </div>
    </div>
  </div>
</div>
<div class="fx-wrap">
  <div class="card" data-href="#">
    <div class="front">
      <div class="image">
        <p class="heading">Shine</p>
      </div>
      <div class="text">
        <header class="clearfix">
          <button class="flip"><span class="zmdi zmdi-replay"></span></button>
        </header>
        <p>Hello, I am another card just proving I work.</p><a href="#">Action</a>
      </div>
    </div>
    <div class="back">
      <div class="text">
        <header class="clearfix">
          <button class="flip"><span class="zmdi zmdi-replay"></span></button>
        </header><b>"Demo it or it didn't happen."</b>
        <p>I am considering making this into a Javascript component so you can all show off your business cards.</p>
      </div>
    </div>
  </div>
</div>
<script src="../js/jquery-1.11.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	'use strict';
$(document).on('click', '.flip', function () {
    var card = $(this).closest('.card');
    if (card.hasClass('flip-it'))
        card.removeClass('flip-it');
    else
        card.addClass('flip-it');
});
$('.card').each(function () {
    var href = $(this).data('href');
    $(this).find('.image').css({
        backgroundImage: [
            'url(',
            href,
            ')'
        ].join('')
    });
});
</script>
	</body>
</html>
